package org.agile.grenoble.resources;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;

import org.agile.grenoble.data.xml.QuestionsReader;
import org.agile.grenoble.questions.QuestionsDocument;

/*
 * commentaire
 */
@Path("/question")
public class QuestionResource {
         // The Java method will process HTTP GET requests
         @GET 
         // The Java method will produce content identified by the MIME Media
         // type "text/plain"
         @Produces("application/xml")
         public String getClichedMessage(@QueryParam("qid") int questionId) {
        	String filename = "/org/agile/grenoble/data/xml/questions.xml";
     		String answers ="<hey>questions</hey>"; 
     		try {
     			QuestionsReader.printItems(filename);
     			System.out.println("coucou");
     			QuestionsDocument questions = QuestionsReader.getDocument(filename);
     			System.out.println("coucou");
     			answers=questions.getQuestions().getQuestionArray(questionId).xmlText();
     		} catch (Exception e) {
     			// TODO Auto-generated catch block
     			e.printStackTrace();
     		}
     		return answers ;
         }
         
}
